package com.apes.framework.plugin.soe.store.database.service;

import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import com.apes.framework.plugin.soe.metadata.Scene;
import com.apes.framework.plugin.soe.metadata.SceneFlow;
import com.apes.framework.plugin.soe.store.database.repository.SceneFlowRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("sceneFlowService")
public class SceneFlowService extends DomainService {

    @Autowired
    SceneFlowRepository sceneFlowRepository;

    public SceneFlow save(SimpleRequest simpleRequest) {
        SceneFlow sceneFlow = simpleRequest.getO(SceneFlow.class);
        sceneFlow = sceneFlowRepository.saveAndFlush(sceneFlow);
        Scene scene = sceneFlow.getScene();
        sendSynEvent("event:scene.check", scene);
        return  sceneFlow;
    }
}
